package liangtWorkSpace.springTest.aopjdbc.impl;

import liangtWorkSpace.springTest.aopjdbc.dao.AccountDao;
import org.springframework.jdbc.core.JdbcTemplate;

/**
 * @author liangt
 * @ClassName: AccountDaoImpl
 * @title: AccountDaoImpl
 * @projectName liangtWorkSpace.springTest.aopjdbc.impl
 * @description: TODO
 * @date 2020/10/13 19:17
 */
public class AccountDaoImpl implements AccountDao {
    private JdbcTemplate jdbcTemplate;
    public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }
    // 汇款的实现方法
    public void out(String outUser, int money) {
        this.jdbcTemplate.update("update account set money =money-? where username =?", money, outUser);
    }
    // 收款的实现方法
    public void in(String inUser, int money) {
        this.jdbcTemplate.update("update account set money =money+? where username =?", money, inUser);
    }
}
